﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Entity;
using OTA.Notification.BO.Dictionary;
using OTA.Notification.Entity.Dictionary;

namespace EZCRS.HCMS.myajax
{
    public class AjaxBaseInfo:MainBase
    {
        ArrayList arrRecord;
        #region proptype 维护
        /// <summary>
        /// 
        /// </summary>
        /// <param name="languagetype"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getallproptype(string languagetype)
        {
            List<HCRS_Proptype> _poplist = new BllPropType().getallproptype(Convert.ToInt32(languagetype));
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tlist\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\" class=\"main-table\"><tr class=\"title1\" height=\"26\"><th width=\"10%\"  >" + EZCRS.HCMS.myajax.Site.StrNumb + "</th><th >" + EZCRS.HCMS.myajax.Site.StrCode + "</th><th>" + EZCRS.HCMS.myajax.Site.StrRemark + "</th><th  width=\"10%\" >" + EZCRS.HCMS.myajax.Site.StrDel + "</th></tr>");
            int row = 0;
            foreach (HCRS_Proptype _pop in _poplist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" onDblClick=\"javascript:modify(this,1,2);\"");
                rstr.Append(" >");
                rstr.Append("<td>"+_pop.Id.ToString()+"</td>");
                rstr.Append("<td>"+_pop.propcode+"</td>");
                rstr.Append("<td>"+_pop.propname+"</td>");
                rstr.Append("<td><img src=\"../../Themes/Standard/Images/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deleteproptype(string id)
        {
            if (new BllPropType().deleteproptype(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertproptype(string popid, string popcode, string popname, string languagetype)
        {
            if (new BllPropType().insertorupdate(Convert.ToInt32(popid), popcode, popname, Convert.ToInt32(languagetype)))
                return "1";
            else
                return "0";
        }
        #endregion

        #region 地区信息维护
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getallcountry()
        {
            int lang = 0;
            List<HCRS_Country> _countrylist = new ZoneBaseInfo().getallcountry(lang);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\" class=\"main-table\"><tr class=\"title1\" height=\"26\"><th width=\"15%\">" + EZCRS.HCMS.myajax.Site.StrNumb + "</th><th >" + EZCRS.HCMS.myajax.Site.StrNumb + "</th><th >" + EZCRS.HCMS.myajax.Site.StrRemark + "</th><th  width=\"20%\" >" + EZCRS.HCMS.myajax.Site.StrDel + "</th></tr>");
            int row = 0;
            foreach (HCRS_Country _country in _countrylist )
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" onDblClick=\"javascript:modify(this,1,2);\"");
                rstr.Append(" >");
                rstr.Append("<td>" + _country.countryid.ToString() + "</td>");
                rstr.Append("<td>" + _country.code + "</td>");
                rstr.Append("<td style=\"cursor:pointer\" onclick=\"getprovince('" + _country.code + "');\">" + _country.countryname + "</td>");
                rstr.Append("<td><img src=\"../../image/modify.gif\"  style=\"cursor:pointer\" onclick=\"javascript:modify(this.parentElement.parentElement,1,2);\" /> <img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deletecountry(string id)
        {
            if (new ZoneBaseInfo().deletecountry(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertcountry(string id,string code,string name)
        {
            HCRS_Country _country = new HCRS_Country();
            _country.countryid = Convert.ToInt32(id);
            _country.code = code;
            _country.countryname = name;
            _country.languagetype = 0;
            if (new ZoneBaseInfo().insertorupdatecountry(_country))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getallprovince(string countryid)
        {
            int lang = 0;
            List<HCRS_Province> _provincelist = new ZoneBaseInfo().getprovince(countryid,lang);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tprovince\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td width=\"15%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCN+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrPinYin+"</td><td  width=\"20%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrDel+"</td></tr>");
            int row = 0;
            foreach (HCRS_Province _province in _provincelist )
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" onDblClick=\"javascript:modify(this,1,2);\"");
                rstr.Append(" >");
                rstr.Append("<td>" + _province.Id.ToString() + "</td>");
                rstr.Append("<td style=\"cursor:pointer\" onclick=\"getcity('" + _province.Id.ToString() + "');\">" + _province.Name + "</td>");
                rstr.Append("<td>" + _province.Remark + "</td>");
                rstr.Append("<td><img src=\"../../image/modify.gif\"  style=\"cursor:pointer\" onclick=\"javascript:modify(this.parentElement.parentElement,1,2);\" /> <img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deleteprovince(string province)
        {
            if (new ZoneBaseInfo().deleteprovince(Convert.ToInt32(province)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertprovince(string id,string name,string remark)
        {
            HCRS_Province _province = new HCRS_Province();
            _province.Id = Convert.ToInt32(id);
            _province.Name = name;
            _province.Remark = remark;
            if (new ZoneBaseInfo().insertorupdateprovince(_province))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getallcity(string provinceid)
        {
            int lang = 0;
            List<HCRS_City> _citylist = new ZoneBaseInfo().getcity(Convert.ToInt32(provinceid), lang);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcity\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\" style=\"word-break:break-all;\"><tr class=\"title1\" height=\"26\"><td width=\"15%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCN+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrPinYin+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLatitude+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLongitude+"</td><td  width=\"30%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrDel+"</td></tr>");
            int row = 0;
            foreach ( HCRS_City _city in _citylist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" style=\"cursor:pointer\" onDblClick=\"javascript:modify(this,1,4);\"");
                rstr.Append(" >");
                rstr.Append("<td>" + _city.Id.ToString() + "</td>");
                rstr.Append("<td>" + _city.Name + "</td>");
                rstr.Append("<td>" + _city.Remark + "</td>");
                rstr.Append("<td>" + _city.Latitude + "</td>");
                rstr.Append("<td>" + _city.Longitude + "</td>");
                rstr.Append("<td><img src=\"../../image/xz.jpg\" title=\""+EZCRS.HCMS.myajax.Site.Strdistrict+"\" style=\"cursor:pointer\" onclick=\"getdistrict('" + _city.Id.ToString() + "');\"> <img src=\"../../image/sy.jpg\" title=\""+EZCRS.HCMS.myajax.Site.StrCommerial+"\" style=\"cursor:pointer\" onclick=\"getcommercial('" + _city.Id.ToString() + "');\"> <img src=\"../../image/modify.gif\"  style=\"cursor:pointer\" onclick=\"javascript:modify(this.parentElement.parentElement,1,4);\" /> <img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deletecity(string id)
        {
            if (new ZoneBaseInfo().deletecity(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertcity(string id,string name,string remark,string latitude,string longitude,string provinceid)
        {
            HCRS_City _city=new HCRS_City();
            _city.Id=Convert.ToInt32(id);
            _city.Latitude=latitude;
            _city.Longitude=longitude;
            _city.Name=name;
            _city.Remark=remark;
            _city.ProvinceID = Convert.ToInt32(provinceid);
            if (new ZoneBaseInfo().insertorupdatecity(_city))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getalldistrict(string cityid)
        {
            int lang = 0;
            List<HCRS_District> _districtlist = new ZoneBaseInfo().getdistrict(Convert.ToInt32(cityid), lang);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tdistrict\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"  style=\"word-break:break-all;\"><tr class=\"title1\" height=\"26\"><td width=\"15%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCN+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrPinYin+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLatitude+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLongitude+"</td><td  width=\"20%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrDel+"</td></tr>");
            int row = 0;
            foreach ( HCRS_District _district in _districtlist )
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\"  style=\"cursor:pointer\" onClick=\"javascript:modify(this,1,4);\"");
                rstr.Append(" >");
                rstr.Append("<td>" + _district.Id.ToString() + "</td>");
                rstr.Append("<td>" + _district.Name + "</td>");
                rstr.Append("<td>" + _district.Remark + "</td>");
                rstr.Append("<td>" + _district.Latitude + "</td>");
                rstr.Append("<td>" + _district.Longitude + "</td>");
                rstr.Append("<td><img src=\"../../image/modify.gif\"  style=\"cursor:pointer\" onclick=\"javascript:modify(this.parentElement.parentElement,1,4);\" /> <img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deletedistrict(string id)
        {
            if (new ZoneBaseInfo().deletedistrict(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertdistrict(string id,string name,string remark,string latitude,string longitude,string cityid)
        {
            HCRS_District _district = new HCRS_District();
            _district.CityID = Convert.ToInt32(cityid);
            _district.Id = Convert.ToInt32(id);
            _district.Name = name;
            _district.Remark = remark;
            _district.Latitude = latitude;
            _district.Longitude = longitude;
            if (new ZoneBaseInfo().insertorupdatedistrict(_district))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getallcommercial(string cityid)
        {
            int lang = 0;
            List<HCRS_Commercial> _commerciallist = new ZoneBaseInfo().getcommercial(Convert.ToInt32(cityid),lang);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcommercial\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"  style=\"word-break:break-all;\"><tr class=\"title1\" height=\"26\"><td width=\"15%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCN+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrPinYin+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLatitude+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrLongitude+"</td><td  width=\"20%\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrDel+"</td></tr>");
            int row = 0;
            foreach ( HCRS_Commercial _commercial in _commerciallist )
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" style=\"cursor:pointer\" onClick=\"javascript:modify(this,1,4);\"");
                rstr.Append(" >");
                rstr.Append("<td>" + _commercial.Id.ToString() + "</td>");
                rstr.Append("<td>" + _commercial.Name + "</td>");
                rstr.Append("<td>" + _commercial.Remark + "</td>");
                rstr.Append("<td>" + _commercial.Latitude + "</td>");
                rstr.Append("<td>" + _commercial.Longitude + "</td>");
                rstr.Append("<td><img src=\"../../image/modify.gif\"  style=\"cursor:pointer\" onclick=\"javascript:modify(this.parentElement.parentElement,1,4);\" /> <img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" /></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deletecommercial(string id)
        {
            if (new ZoneBaseInfo().deletecommercial(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updateorinsertcommercial(string id, string name, string remark, string latitude, string longitude, string cityid)
        {
            HCRS_Commercial _commercial = new HCRS_Commercial();
            _commercial.CityID = Convert.ToInt32(cityid);
            _commercial.Id = Convert.ToInt32(id);
            _commercial.Name = name;
            _commercial.Remark = remark;
            _commercial.Latitude = latitude;
            _commercial.Longitude = longitude;
            if (new ZoneBaseInfo().insertorupdatecommercial(_commercial))
                return "1";
            else
                return "0";
        }
        #endregion

        #region 酒店设施维护
        #endregion

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getbaseinfotype(string types,string codes)
        {
            string pid = base.BasPropertyId.ToString();
            string gid = BasGroupId.ToString();
            string sqlstr = " type=" + CFun.VerifySQL(types)+" and languagetype="+base.LanguageId.ToString()+"";
            if (codes != "0")
            {
                if (pid != "0")
                    sqlstr += " and pid=" + pid ;
                else
                    return EZCRS.HCMS.myajax.Site.StrSelectHotel ;
            }
            List<HCRS_Baseinfo> _poplist = new Bllbase_info().getitem(sqlstr);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tlist\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\" class=\"main-table\"><tr class=\"title1\" height=\"26\"><th width=\"10%\" >" + EZCRS.HCMS.myajax.Site.StrNumb + "</th><th >" + EZCRS.HCMS.myajax.Site.StrCode + "</th><th >" + EZCRS.HCMS.myajax.Site.StrName + "</th><th>" + EZCRS.HCMS.myajax.Site.StrRank + "</th><th >" + EZCRS.HCMS.myajax.Site.StrPid + "</th><th  width=\"10%\" >" + EZCRS.HCMS.myajax.Site.StrDel + "</th></tr>");
            int row = 0;
            foreach (HCRS_Baseinfo _pop in _poplist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");

                if (codes != "0")
                    rstr.Append(" onDblClick=\"javascript:modify(this,1,4);\"");
                else if (pid == "0")
                    rstr.Append(" onDblClick=\"javascript:modify(this,1,4);\"");
                    
                rstr.Append(" >");
                rstr.Append("<td>" + _pop.id.ToString()+ "</td>");
                rstr.Append("<td>" + _pop.code + "</td>");
                rstr.Append("<td>" + _pop.name + "</td>");
                rstr.Append("<td>" + _pop.rank.ToString() + "</td>");
                rstr.Append("<td>" + _pop.pid.ToString() + "</td>");
                rstr.Append("<td>");

                if (codes != "0")
                    rstr.Append("<img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" />");
                else if (pid == "0" && gid=="0")
                    rstr.Append("<img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" />");

                rstr.Append("</td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string deletebaseinfo(string id)
        {
            if (new Bllbase_info().deleteitem(Convert.ToInt32(id)))
                return "1";
            else
                return "";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updatebaseinfo(string jsid,string jscode,string jsname,string jsrank,string jspid,string jstype)
        {
            HCRS_Baseinfo _info = new HCRS_Baseinfo();
            _info.id = Convert.ToInt32(jsid);
            _info.code = jscode;
            _info.name = jsname;
            _info.pid = Convert.ToInt32(jspid);
            _info.rank = Convert.ToInt32(jsrank);
            _info.type = Convert.ToInt32(jstype);
            _info.languagetype = base.LanguageId;

            if (new Bllbase_info().insertorupdateitem(_info))
                return "1";
            else
                return "";
        }

       
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public ArrayList getbasecompany(int cpage, string companycode, string companyname)
        {
            #region
            arrRecord = new ArrayList();

            
            string sqlstr = "";

            if (companycode != "")
                sqlstr = " COMPANY_CODE='" + CFun.VerifySQL(companycode) + "'";
            if (companyname != "")
            {
                if (sqlstr != "")
                    sqlstr += " and ";
                sqlstr += " SHORT_NAME like '%" + CFun.VerifySQL(companyname) + "%'";
            }

            int iPageCount = 0;

            //组合字符串
            IList<OTA_DICTIONARY> dlist = new DictionaryBO().getAllDictionary("TVS", OTA.Notification.Common.DicType.Common, OTA.Notification.Common.LanguageType.English);
            
            List<HCRS_COMPANY> companylist = new BllHCRS_COMPANY().getallbypage(cpage, out iPageCount, sqlstr);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tlist\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\"><tr class=\"title1\" height=\"26\"><td width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrNumb + "</td><td style=\"color: white;\">公司标识</td><td style=\"color: white;\">公司简称</td><td style=\"color: white;\">类别</td><td style=\"color: white;\">其他</td><td style=\"color: white;\">最后修改人/时间</td><td style=\"color: white;\">创建人/时间</td><td  width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrDel + "</td></tr>");
            int row = 0;
            foreach (HCRS_COMPANY company in companylist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");
                rstr.Append(" >");
                rstr.Append("<td>" + company.id.ToString() + "</td>");
                rstr.Append("<td>" + company.COMPANY_CODE + "</td>");
                rstr.Append("<td>" + company.SHORT_NAME + "</td>");
                rstr.Append("<td>" );
                foreach (OTA_DICTIONARY dict in dlist)
                {
                    if (dict.VALUE == Convert.ToInt32(company.TRAVEL_SECTOR))
                    {
                        rstr.Append(dict.NAME);
                        break;
                    }
                }
                rstr.Append("</td>");
                rstr.Append("<td>" + company.DIVISION + "</td>");

                rstr.Append("<td>" + company.UPDATE_USER_NAME + "<br>" + company.LAST_UPDATE_TIME.ToString() + "</td>");
                rstr.Append("<td>" + company.CREATE_USER_NAME + "<br>" + company.CREATE_TIME.ToString() + "</td>");

                rstr.Append("<td>");
                rstr.Append("<img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" />");
                rstr.Append("</td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            //将表格放入arraylist
            arrRecord.Add(rstr.ToString());
            //将总页数放入arraylist
            arrRecord.Add(iPageCount.ToString() == "0" ? "1" : iPageCount.ToString());
            //将总记录数放入arraylist
            arrRecord.Add("0");

            return arrRecord;
            #endregion
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public ArrayList getbasepartner(int cpage,string types, string codes)
        {
            arrRecord = new ArrayList();

            string sqlstr = "";
            if (types != "")
                sqlstr = " PARTNER_TYPE ='"+CFun.VerifySQL(types)+"'";
            if (codes != "")
            {
                if (sqlstr != "")
                    sqlstr += " and ";
                sqlstr += " COMPANY_CODE ='"+CFun.VerifySQL(codes)+"'";
            }
            int iPageCount=0;
            IList<OTA_DICTIONARY> dlist = new DictionaryBO().getAllDictionary("UIT", OTA.Notification.Common.DicType.Common, OTA.Notification.Common.LanguageType.English);

            List<HCRS_PARTNER> partnerlist = new BllHCRS_PARTNER().getallbypage(cpage, out iPageCount, sqlstr);
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tlist\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\"><tr class=\"title1\" height=\"26\"><td width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrNumb + "</td><td style=\"color: white;\">地址</td><td style=\"color: white;\">类型</td><td style=\"color: white;\">实例</td><td style=\"color: white;\">消息密码</td><td style=\"color: white;\">公司编号</td><td style=\"color: white;\">最后修改人/最后修改时间</td><td style=\"color: white;\">创建人/创建时间</td><td  width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrDel + "</td></tr>");
            int row = 0;
            foreach (HCRS_PARTNER partner in partnerlist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");

                rstr.Append(" >");
                rstr.Append("<td>" + partner.id.ToString() + "</td>");
                rstr.Append("<td>" + partner.PARTNER_URL + "</td>");
                rstr.Append("<td>" );

                foreach (OTA_DICTIONARY dict in dlist)
                {
                    if (dict.VALUE == Convert.ToInt32(partner.PARTNER_TYPE))
                    {
                        rstr.Append(dict.NAME);
                        break;
                    }
                }

                rstr.Append("</td>");
                rstr.Append("<td>" + partner.PARTNER_INSTANCE + "</td>");
                rstr.Append("<td>" + partner.MESSAGEPASSWORD + "</td>");
                rstr.Append("<td>" + partner.COMPANY_CODE + "</td>");
                rstr.Append("<td>" + partner.LAST_USER_NAME+"<br>"+partner.LAST_UPDATE_TIME.ToString() + "</td>");
                rstr.Append("<td>" + partner.CREATE_USER_NAME+"<br>"+ partner.CREATE_TIME.ToString()+ "</td>");
                rstr.Append("<td>");
                rstr.Append("<img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" />");
                rstr.Append("</td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");

            rstr.Append("</table>");
            //将表格放入arraylist
            arrRecord.Add(rstr.ToString());
            //将总页数放入arraylist
            arrRecord.Add(iPageCount.ToString() == "0" ? "1" : iPageCount.ToString());
            //将总记录数放入arraylist
            arrRecord.Add("0");

            return arrRecord;
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string delbasecompany(string id)
        {
            if (new BllHCRS_COMPANY().deleteitem(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string delbasepartner(string id)
        {
            if (new BllHCRS_PARTNER().deleteitem(Convert.ToInt32(id)))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getmodulehelp(int mid)
        {
            List<hfg_module_help> helplist = new Bllhfg_module_help().getitem(" mid="+mid.ToString()+" ");
            
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tlist\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\"><tr class=\"title1\" height=\"26\"><td width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrNumb + "</td><td style=\"color: white;\">信息</td><td style=\"color: white;\">排序</td><td style=\"color: white;\">编辑</td><td  width=\"10%\" style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrDel + "</td></tr>");
            int row = 0;
            foreach (hfg_module_help help in helplist)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");

                rstr.Append(" >");
                rstr.Append("<td>" + help.id.ToString() + "</td>");
                rstr.Append("<td>" + help.comment + "</td>");
                rstr.Append("<td>" + help.rank.ToString() + "</td>");

                rstr.Append("<td><a href=\"#\" onclick=\"javascript:modify(this);\">编辑</a></td>");
                rstr.Append("<td>");
                rstr.Append("<img src=\"../../image/delete.gif\"  style=\"cursor:hand\" onclick=\"javascript:del(this);\" />");
                rstr.Append("</td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");


            return rstr.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string savemodulehelp(int id,int mid,int rank, string comment)
        {
            hfg_module_help help = new hfg_module_help();
            if (id != 0)
                help.id = id;
            help.comment = CFun.RemoveHtml(comment);
            help.mid = mid;
            help.rank = rank;

            if (new Bllhfg_module_help().insertorupdateitem(help))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string delmodulehelp(int id)
        {
            if (new Bllhfg_module_help().deleteitem(id))
                return "1";
            else
                return "0";
        }
    }
}
